package com.zkah.aes;

import com.zkah.aes.utils.AesUtil;

public class Demo {
    public static final String TOKEN = "E10C90F36A760025A4AF3D69D7EEFEDA";
    public static final String CODE = "yangmeierkuang";
    public static final String API_PARAM_KEY_TOKEN = "token";
    public static final String API_PARAM_KEY_MINECODE = "mineCode";
    public static void main1(String[] args) {
        String tempToken = "token=" + TOKEN + "&mineCode=" + CODE;
        String ciphertext = null;
        try {
            ciphertext = AesUtil.encryptWithIV(tempToken,TOKEN);
        } catch (Exception e) {
            e.printStackTrace();
        }
        //dyiPfyZ7kRJasDrjO2XJn7t98f37VQhxOJIkbUNK+U/amQRnFPMGV6Of2OA5pJhg5PDe5IYeVdillSGBCiXy1g==
        System.out.println(ciphertext);

    }
    public static void main(String[] args){
        String params = null;
        String decryptMineCode = null;
        String decryptToken = null;
        try {
            params = AesUtil.decryptWithIV("dyiPfyZ7kRJasDrjO2XJn7t98f37VQhxOJIkbUNK+U/amQRnFPMGV6Of2OA5pJhg5PDe5IYeVdillSGBCiXy1g==",TOKEN);
            for(String param:params.split("&")){
                String[] str = param.split("=");
                if(API_PARAM_KEY_MINECODE.equals(str[0])){
                    decryptMineCode=str[1];
                }else if(API_PARAM_KEY_TOKEN.equals(str[0])){
                    decryptToken=str[1];
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println(decryptMineCode);
        System.out.println(decryptToken);
    }
}
